﻿<script src="~/Scripts/jquery-easyui-extensions/datagrid/jeasyui.extensions.datagrid.getDom.js"></script>
<script src="~/Scripts/jquery-easyui-extensions/datagrid/jeasyui.extensions.datagrid.highlightColumn.js"></script>

<div class="easyui-panel" data-options="fit:true,border:false">
    <table id="dg1"></table>
</div>

<script>
    $(function () {
        var getFrozenColumns = function () {
            var result = [];

            var c1 = [];
            c1.push({
                field: 'ID', title: '索引', width: 100,
                formatter: function (val, row, index) {
                    return index;
                }
            });
            c1.push({ field: 'AreaName', title: '地区', width: 180 });
            c1.push({ field: 'Sex1', title: '男', width: 90 });
            c1.push({ field: 'Sex2', title: '女', width: 90 });

            result.push(c1);

            return result;
        };

        var getColumns = function () {
            var result = [];

            var normal00000 = [
                { field: 'TS1', title: '测试1', width: 60 },
                { field: 'TS2', title: '测试2', width: 60 }
            ];
            result.push(normal00000);

            return result;
        };
        var options = {
            title: "列表",
            idField: "ID",
            rownumbers: false,
            fit: true,
            border: false,
            singleSelect: true,
            toolbar: [
                {
                    iconCls: 'icon-edit',
                    text: "高亮“女”列",
                    handler: function () {
                        $("#dg1").datagrid("highlightColumn", "Sex2");
                    }
                },
                "-",
                {
                    iconCls: 'icon-edit',
                    text: "高亮“测试2”列",
                    handler: function () {
                        $("#dg1").datagrid("highlightColumn", "TS2");
                    }
                }
            ],
            frozenColumns: getFrozenColumns(),
            columns: getColumns(),
            method: "get",
            url: "/Jsons/datagrid/datagrid-common-data.json",
            autoHighlightColumn: true
        };

        $("#dg1").datagrid(options);
    });
</script>